var swiper1 = new Swiper('.nav .swiper-container', {
    pagination: '.swiper-pagination',
    slidesPerView: 5,
    paginationClickable: true,
    spaceBetween: 30,
    freeMode: true
}); 
var swiper = new Swiper('.banner>.swiper-container', {
    pagination: '.swiper-pagination',
    paginationClickable: true
});
var swiper2 = new Swiper('.main>.swiper-container', {
    paginationClickable: true,
     onSlideChangeEnd: function(swiper2) {//回调函数，过渡动画结束后执行，即滑块活动停止后执行
        swiper1.clickedIndex = swiper2.activeIndex;
        swiper1.slides.eq(swiper2.activeIndex).trigger('click');
        $("window").scroll("0")
     
    },
});

        
swiper1.container.on("click",".swiper-slide", function(){
    var slide = swiper1.slides.eq(swiper1.clickedIndex);
    console.log(this)
    slide.addClass("active").siblings().removeClass("active");
        var swiperHalf = swiper1.width / 2;
        var maxTranslate = swiper1.maxTranslate();
        var maxWidth = -maxTranslate + swiperHalf;
        var slideLeft = slide[0].offsetLeft;
        var slideWidth = slide[0].clientWidth;
        var slideCenter = slideLeft + slideWidth / 2;
        // 被点击slide的中心点
        swiper1.setWrapperTransition(300);
        if (slideCenter < swiperHalf) {
            swiper1.setWrapperTranslate(0);
        } else if (slideCenter > maxWidth) {
            swiper1.setWrapperTranslate(maxTranslate);
        } else {
            var translate = slideCenter - swiperHalf;
            swiper1.setWrapperTranslate(-translate);
        }
    swiper2.slideTo(swiper1.clickedIndex);//slideTo 设置为true则点击slide时会在这个slide产生过渡
});
$.ajax({
    url:"json/zzs.json",
    type:"get",
    dataType:"json",
    success:function (data) {
      var str =  template("szz",{list:data});
      $(".szz").append(str);
    }
});
$.ajax({
    type: "GET",
    url: "json/gwc.json",
    dataType: 'json',
    success: function (data) {
        res = data.filter(function (v) {
            return v.number == 0;
        });
        var str = template("moban", { arr: res });
        $('.cnxh').html(str);
    }
});
$('.fl-search').click(function () {
    location.href = "html/search.html";
})

        
  

